home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / bndread / readonly.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-05-07  |  3.8 KB  |  120 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Data Control with Bound ReadOnly Text boxes"
  4.    ClientHeight    =   3825
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1485
  7.    ClientWidth     =   6120
  8.    Height          =   4230
  9.    Left            =   1035
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   3825
  12.    ScaleWidth      =   6120
  13.    Top             =   1140
  14.    Width           =   6240
  15.    Begin CommandButton Command2 
  16.       Caption         =   "Push to make Read/Write"
  17.       Height          =   495
  18.       Left            =   3240
  19.       TabIndex        =   1
  20.       Top             =   2280
  21.       Width           =   2415
  22.    End
  23.    Begin CommandButton Command1 
  24.       Caption         =   "Push to make ReadOnly"
  25.       Height          =   495
  26.       Left            =   600
  27.       TabIndex        =   0
  28.       Top             =   2280
  29.       Width           =   2295
  30.    End
  31.    Begin TextBox Text2 
  32.       DataField       =   "Author"
  33.       DataSource      =   "Data1"
  34.       Height          =   375
  35.       Left            =   2040
  36.       TabIndex        =   3
  37.       Top             =   1440
  38.       Width           =   2415
  39.    End
  40.    Begin TextBox Text1 
  41.       DataField       =   "Au_ID"
  42.       DataSource      =   "Data1"
  43.       Height          =   375
  44.       Left            =   2640
  45.       TabIndex        =   2
  46.       Top             =   600
  47.       Width           =   1815
  48.    End
  49.    Begin Data Data1 
  50.       Caption         =   "Data1"
  51.       Connect         =   ""
  52.       DatabaseName    =   "C:\vb\BIBLIO.MDB"
  53.       Exclusive       =   0   'False
  54.       Height          =   270
  55.       Left            =   2040
  56.       Options         =   0
  57.       ReadOnly        =   0   'False
  58.       RecordSource    =   "Authors"
  59.       Top             =   3240
  60.       Width           =   2415
  61.    End
  62.    Begin Label Label3 
  63.       Alignment       =   2  'Center
  64.       AutoSize        =   -1  'True
  65.       Caption         =   "Default is set to Read/Write"
  66.       FontBold        =   -1  'True
  67.       FontItalic      =   -1  'True
  68.       FontName        =   "MS Sans Serif"
  69.       FontSize        =   9.75
  70.       FontStrikethru  =   0   'False
  71.       FontUnderline   =   0   'False
  72.       Height          =   240
  73.       Left            =   1635
  74.       TabIndex        =   6
  75.       Top             =   0
  76.       Width           =   2985
  77.    End
  78.    Begin Label Label2 
  79.       Caption         =   "Author Name:"
  80.       Height          =   255
  81.       Left            =   600
  82.       TabIndex        =   5
  83.       Top             =   1440
  84.       Width           =   1335
  85.    End
  86.    Begin Label Label1 
  87.       Caption         =   "Author Identification:"
  88.       Height          =   255
  89.       Left            =   600
  90.       TabIndex        =   4
  91.       Top             =   600
  92.       Width           =   1815
  93.    End
  94. Option Explicit
  95. Dim readonly_flag%
  96. Sub check_if_readonly (keyascii As Integer)
  97.  If keyascii > 0 And readonly_flag% = 1 Then     '** if they press any key and readonly_flag% = 1 then
  98.   keyascii = 0                                   '** turn keystroke off
  99.  End If
  100. End Sub
  101. Sub Command1_Click ()
  102.  data1.ReadOnly = True       '*** set the incoming data to readonly
  103.  readonly_flag% = 1          '*** set readonly_flag% to 1 to makde text boxes readonly
  104.  label3.Caption = "ReadOnly record"
  105. End Sub
  106. Sub Command2_Click ()
  107.  data1.ReadOnly = False      '*** set the incoming data to read/write
  108.  readonly_flag% = 0          '*** set readonly_flag% to 0 to make text boxes read/write
  109.  label3.Caption = "Read/Write record"
  110. End Sub
  111. Sub Form_Load ()
  112.  readonly_flag% = 0        '** set default to read/write
  113. End Sub
  114. Sub Text1_KeyPress (keyascii As Integer)
  115.  Call check_if_readonly(keyascii)
  116. End Sub
  117. Sub Text2_KeyPress (keyascii As Integer)
  118.  Call check_if_readonly(keyascii)
  119. End Sub
  120.